package com.day13_Internet;

import java.net.InetAddress;
import java.net.UnknownHostException;

/**
 * @ClassName: InetAddressDemo
 * @Author: zw
 * @Description: 出百万拳，行万里路；
 * @Create 2024/3/24-10:08
 * @Version 1.0
 */
public class InetAddressDemo {
    public static void main(String[] args) throws UnknownHostException {
        // 通过传入ip地址获取主机的ip地址
        InetAddress address = InetAddress.getByName("192.168.3.7");
        System.out.println(address);
        // 获取此ip地址的主机名称
        String hostname = address.getHostName();
        System.out.println(hostname);
        // 返回文本显示的ip地址字符串
        System.out.println(address.getHostAddress());
    }
}
